package com.edu.exam.entity.classmanagement.administrative;

// AssignmentType枚举现在在同一个包中，无需import
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 学生班级分配实体类
 * 所属模块：F-05 行政班级管理模块
 * 对应数据库表：student_class_assignment
 *
 * 管理学生与行政班级之间的关联关系。
 * 支持学生班级的分配、查询和状态管理。
 * 记录分配时间、分配类型等关键信息，提供学生班级分配的完整视图。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "student_class_assignment")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class StudentClassAssignment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank(message = "学生ID不能为空")
    @Size(max = 50, message = "学生ID长度不能超过50个字符")
    @Column(name = "student_id", nullable = false, length = 50)
    private String studentId;

    @NotNull(message = "班级ID不能为空")
    @Column(name = "class_id", nullable = false)
    private Long classId;

    @Enumerated(EnumType.STRING)
    @Column(name = "assignment_type", nullable = false, length = 20)
    @Builder.Default
    private AssignmentType assignmentType = AssignmentType.MANUAL;

    @NotNull(message = "分配时间不能为空")
    @CreatedDate
    @Column(name = "assign_time", nullable = false, updatable = false)
    private LocalDateTime assignTime;

    @Size(max = 50, message = "分配人长度不能超过50个字符")
    @Column(name = "assign_by", length = 50)
    private String assignBy;

    @Size(max = 200, message = "分配原因长度不能超过200个字符")
    @Column(name = "assign_reason", length = 200)
    private String assignReason;

    @Column(name = "is_active", nullable = false)
    @Builder.Default
    private Boolean isActive = true;

    @Column(name = "deleted", nullable = false)
    @Builder.Default
    private Boolean deleted = false;

    
    // 业务逻辑方法
}
